Skip to content

Conversation

rpurser47
Copy link
Member

The proposed organization is meant for toolboxes that implement MEX functions using C/ C++/ Fortran for implementing features. They might also interface with external libraries.

@rpurser47 rpurser47 requested review from gulley and bpancras October 23, 2024 19:46
@rpurser47 rpurser47 self-assigned this Oct 23, 2024
@rpurser47
Copy link
Member Author

This will require internal MathWorks review before it's merged into main.

@rpurser47 rpurser47 marked this pull request as ready for review October 23, 2024 19:46
Copy link
Member

@gulley gulley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

I'm glad this is its own standalone document and not part of the main Toolbox Design doc.

At the top, maybe give etymology of MEX as "MATLAB EXecutable file".

"Let's explore the world of MEX integration!" This sounds a little too ChatGPT chirpy.

Maybe mention earlier that the actual compiled MEX files themselves are derived via the build process and so don't even appear in the folder. We only see, for example, subtract.m and subtract.cpp.

We should be clear about the fact that derived files shouldn't be checked into revision control. The whole concept of derived files is alien to a lot of our pure MATLAB users (i.e. they never really trained on any other language or language ecosystem).

Typo? line 47 "mex function" => "MEX function"?

@rpurser47 rpurser47 linked an issue Jul 17, 2025 that may be closed by this pull request
@rpurser47
Copy link
Member Author

@bpancras All these changes look good to me.

…ndation to create a "derived" folder in place of the private folder solution to address AndyC feedback.
…ubfolder> under <folder>"

* Added a "don't assume performance is better" comments to mex.md
* Draft integration of mex.md file references into the main README.md
* Minor editorial
@rpurser47 rpurser47 marked this pull request as draft September 7, 2025 09:28
@rpurser47 rpurser47 marked this pull request as ready for review September 7, 2025 09:29
@rpurser47
Copy link
Member Author

rpurser47 commented Sep 7, 2025

OK, here's what I believe to be a near-complete proposed version that addresses add internal and external feedback. Key items:

  • Addressed concerns about out-of-source vs in-source builds through the use of a toolbox/derived folder
  • Added info about MEX functions not allowed on file exchange
  • General editorial improvements and responded to other internal and external feedback
  • Added spell check list for Code Spell Checker" VSCode extension from Street side software

Tagging @colbysparks in case he wants to look at it again.

@rpurser47 rpurser47 changed the title Initial draft of MEX best practice MEX best practice Sep 8, 2025
Tweaked recommendation around end users calling your MEX file. I removed the discussion of performance and wrappers. I think the recommendation is strong enough as worded - don't let users call your stuff directly. It's obvious that this means it's only called from your toolbox code.

Readers should then be able to infer that if they want to give the MEX functionality directly to end users, they should wrap a MATLAB function around it to handle arguments safely. And there's nothing to suggest that they should create a wrapper function just if they are calling within their own code.
@rpurser47
Copy link
Member Author

@michellehirsch -- your change looks good. Thanks. Any comments, @bpancras, @gulley , or @acampbel ? I'm going to move forward with the merge EOD (Natick) Wednesday 9/10.

@bpancras
Copy link
Collaborator

LGTM

@rpurser47 rpurser47 closed this Sep 11, 2025
@rpurser47 rpurser47 reopened this Sep 11, 2025
@rpurser47 rpurser47 merged commit edeada9 into main Sep 11, 2025
@rpurser47 rpurser47 deleted the mex-wip branch September 11, 2025 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Best practices for distributing MEX files with toolboxes
5 participants